home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 3565-4.665 / dmg-4385 / issue_10 / 23.pne < prev    next >
Text File  |  1987-04-21  |  33KB  |  1,192 lines

  1.  
  2.  
  3. ****************************************************************
  4.   Tony here....Before you start on this months tutorial i 
  5. must explain something, As usual William has done you all 
  6. proud by bringing you another massive packed tutorial, I tried 
  7. writing a tutorial and beleive me it is very hard work, 
  8.  
  9.  Well this months tutorial is so big that i have had to split 
  10. it into two seperate files, Both are in this issue of course, 
  11. And as usual all the relative files ASC's etc are in a folder 
  12. on this disk, So it is Basic Tut 10/1 AND basic Tut 10/2, They 
  13. are next to each other on the menu so there shouldent be a 
  14. problem, 
  15. ***************************************************************
  16.  
  17. I assume little/no prior knowledge of Stos.  Each lesson will also 
  18. have a Stos BASic or ASCii file to go with it.
  19.  
  20. Listed here for your convenience.  i.e. to make it easier to write 
  21. them down or to look at the structure of the command. Are the new
  22. commands to be dealt with.
  23.  
  24. Do not worry if you find things hard at first, practice makes 
  25. perfect. Actual progs are used to explain things, called
  26. 'name.asc' and included in this folder.
  27.  
  28. The Main Commands:
  29.  
  30. SET ZONE:   RESET ZONE:     READ:     RESTORE:
  31. COPY TO:    UNSQUASH:
  32. RESERVE SCREEN:   SCREEN COPY:   GET PALETTE:
  33.  
  34. If you have any problems, then look for the command on pages 271/73 
  35. of the manual.  This is not intended to replace the manual,
  36. but to add to it where needed. 
  37.  
  38.  
  39. Right then, before I start I had better explain where the idea for 
  40. this jigsaw programme came from.  When I first saw Stos 3D, I saw 
  41. that it was possible to create cubes.  I then thought of filling 
  42. the screen with cubes, so that each cube had part of a picture on 
  43. it.  This would allow a 6-picture jigsaw, one jigsaw per face on 
  44. the cube, but I never got around to mastering Stos 3D.
  45.  
  46. I think that I said that I intended to finish the jigsaw programme 
  47. this time, well sadly that is not to be.  As the programmes 
  48. themselves take up around 21 pages - each one is printed twice - I 
  49. have decided that I would have had to jump too far from subgect to 
  50. subject, in order to cram it all in.
  51.  
  52. So, this month sees the jigsaw up and running, but with no checks 
  53. to see if the jigsaw is completed, or completed corectly.  Next 
  54. month will deal with squashing, and the month after that will deal 
  55. with the complete jigsaw programme.
  56.  
  57.         This way, I can give you some pictures to load into the jigsaw 
  58. programme.  As they will be packed to save space, there was little 
  59. point in including them in this tutorial.  But I will include some 
  60. for the next two tutorials - all being well.
  61.  
  62.  
  63. And on to the tutorial.  The first two lessons deal with setting 
  64. up zones to detect things, and then the there are three versions 
  65. of the jigsaw programme - although only the final one is really 
  66. complete. the other two just being demos.
  67.  
  68.  
  69. LESSON 1
  70.  
  71. This lesson justs draws boxes and zones to screen, and then ends.
  72.  
  73. 10 rem-----------------------------
  74. 20 rem----                     ----
  75. 30 rem----     SET ZONES      ----
  76. 40 rem----                     ----
  77. 50 rem-----------------------------
  78. 60 cls : key off
  79. 70 if mode<>0 then mode 0
  80. 80 reset zone
  81. 90 for F=1 to 9
  82. 100 read A,B,C,D 
  83. 110 set zone F,A,B to C,D 
  84. 120 box A,B to C,D 
  85. 130 next F 
  86. 140 data 0,0,32,18,32,0,63,18 
  87. 150 data 0,19,32,37,32,19,63,37 
  88. 160 data 0,38,32,66,32,38,63,66 
  89. 170 data 0,67,32,95,32,67,63,95 
  90. 180 data 0,96,63,119 
  91.  
  92. And what it does.
  93.  
  94. Lines:
  95. 10 rem-----------------------------
  96. 20 rem----                     ----
  97. 30 rem----     SET ZONES      ----
  98. 40 rem----                     ----
  99. 50 rem-----------------------------
  100.  
  101. Are the title.  Sometimes I number the first of a series, somtimes 
  102. I only number from the second in the series.  So this really 
  103. should have been 'SET ZONES 1', but it is not that important.
  104.  
  105. Lines:
  106. 60 cls : key off
  107. 70 if mode<>0 then mode 0
  108.  
  109. Set up the screen.  The screen is cleared, and then the menu at 
  110. the top of the screen is removed, and then the screen resolution 
  111. is checked and altered if needed.  In actual fact.  The KEY OFF 
  112. command is in the wrong place.
  113.  
  114. The programme clears the screen, then displays the menu, then has 
  115. it removed, and then checks the resolution.  If the resolution is 
  116. changed, then the menu will reappear.  This the KEY OFF really 
  117. should be on its own line, and after the CLS; and MODE commands.
  118.  
  119. Line
  120. 80 reset zone
  121.  
  122. Resets the zones.  This clears any zones on screen, so that they 
  123. will not interfear with the ones being drawn.  If zones overlap 
  124. then two zones could be activated at the same time.  Usually you 
  125. want to avoid this, as it makes for trouble.
  126.  
  127. Line:
  128. 90 for F=1 to 9
  129. Sets up a routine to draw 9 boxes and zones.  The boxes are there 
  130. to show where the zones are.  In a proper programme you would more 
  131. than likely not want to draw boxes, as it is usually quicker, and 
  132. easier, to swap the whole screen.
  133.  
  134. Line:
  135. 100 read A,B,C,D
  136. The READ command looks for the first data statement that it can 
  137. find, and reads it, then the next one and so on.  In this case it 
  138. reads four numbers which will be the locations for the box and 
  139. zone to be drawn.
  140.  
  141. The 'A B C D' is used to manipulate the numbers.  READ would work 
  142. just as well if it had been 4 'A's or 4'B's.  But then it would 
  143. have been harder to make use of the values as it would change four 
  144. times.  This way the values remani the same until they have to be 
  145. changed.
  146.  
  147. Lines:
  148. 110 set zone F,A,B to C,D
  149. 120 box A,B to C,D
  150.  
  151. Set up the zones and draw the boxes to the same place.  'F' will 
  152. increase each time it is read, so each time it will apply to a 
  153. different zone.  The 'A B C D' will advance by the number of data 
  154. variables read - in this case 4 at a time.  In order to read the 
  155. first data statement again, you would use a RESTORE command, or 
  156. RESTORE line number to jump to specific data.
  157.  
  158. Line:
  159. 130 next F
  160.  
  161. Closes the looping routine.
  162.  
  163. Lines:
  164. 140 data 0,0,32,18,32,0,63,18
  165. 150 data 0,19,32,37,32,19,63,37
  166. 160 data 0,38,32,66,32,38,63,66
  167. 170 data 0,67,32,95,32,67,63,95
  168. 180 data 0,96,63,119   
  169.  
  170. Hold the data.  I decided to put two lots of data into the first 
  171. four lines and one in the final line.  So the programme READs the 
  172. first four numbers of line 140, then draws the boxes and zones.  
  173. Then the next four lines are read.  It does not matter how much 
  174. data is on each line.  I could have put all the data on one line 
  175. if I had wanted.
  176.  
  177. So why choose the setup that I did.  Well if the data is read in 
  178. sequance, then the first line refers to the first two boxes drawn. 
  179. These boxes happen to be drawn side by side, so I decided to place 
  180. them together as data statements.
  181.  
  182. Basically, the idea is to make it more logical for me/you to read 
  183. and understand.  Also if you use large lines of data, it is harder 
  184. to spot an error, and almost imposible to use RESTORE to 
  185. manipulate the data.
  186.  
  187. I will be covering RESTORE later on, so do not worry about it.
  188.  
  189.  
  190.  
  191. lesson 2
  192.  
  193. This is lesson 1, but with test routines to show you that the 
  194. zones are working.
  195.  
  196. 10 rem-----------------------------
  197. 20 rem----                     ----
  198. 30 rem----     SET ZONES  2   ----
  199. 40 rem----                     ----
  200. 50 rem-----------------------------
  201. 60 cls : key off : curs off : clear key
  202. 70 if mode<>0 then mode 0
  203. 80 reset zone
  204. 90 for F=1 to 9
  205. 100 read A,B,C,D
  206. 110 set zone F,A,B to C,D
  207. 120 box A,B to C,D
  208. 130 next F
  209. 140 rem
  210. 150 locate 11,5 : print "Press a key to quit"
  211. 160 locate 9,7 : print "Use mouse to test Zones"
  212. 170 rem
  213. 180 rem
  214. 190 rem
  215. 200 locate 10,10
  216. 210 print zone(0)
  217. 220 rem
  218. 230 MK=0
  219. 240 repeat
  220. 250 K$=inkey$
  221. 260 if K$<>"" then default : end
  222. 270 MK=mouse key
  223. 280 until MK<>0 
  224. 290 rem 
  225. 300 locate 10,10 
  226. 330 print zone(0) 
  227. 350 goto 200 
  228. 1000 data 0,0,32,18,32,0,63,18 
  229. 1010 data 0,19,32,37,32,19,63,37 
  230. 1020 data 0,38,32,66,32,38,63,66 
  231. 1030 data 0,67,32,95,32,67,63,95 
  232. 1040 data 0,96,63,119 
  233. 1230 data 0,67,32,95,32,67,63,95 
  234.  
  235.  
  236. A bit longer, and not logically numbered in places.  I forgot to 
  237. renumber it, and now it is too late to mess around.
  238.  
  239. Lines 340 was deleted and line 1230 is just numbered wrongly.  A 
  240. renum would have put it right but I forgot.
  241.  
  242. Lines:
  243. 10 rem-----------------------------
  244. 20 rem----                     ----
  245. 30 rem----     SET ZONES  2   ----
  246. 40 rem----                     ----
  247. 50 rem-----------------------------
  248.  
  249. Are the title of the programme.
  250.  
  251. Lines:
  252. 60 cls : key off : curs off : clear key
  253. 70 if mode<>0 then mode 0
  254. 80 reset zone
  255. 90 for F=1 to 9
  256. 100 read A,B,C,D
  257. 110 set zone F,A,B to C,D
  258. 120 box A,B to C,D
  259. 130 next F
  260.  
  261. Are the same as lesson 1, so I wont add  anything more.
  262.  
  263. Lines:
  264. 140 rem
  265. 150 locate 11,5 : print "Press a key to quit"
  266. 160 locate 9,7 : print "Use mouse to test Zones"
  267.  
  268. Print messages to screen informing you of how to quit the 
  269. programme.
  270.  
  271. Lines:
  272. 170 rem
  273. 180 rem
  274. 190 rem
  275. 200 locate 10,10
  276. 210 print zone(0)
  277.  
  278. Print the current zone to screen.  The current zone - in this case 
  279. is whichever zone the mouse pointer is over.
  280.  
  281. Lines:
  282. 220 rem
  283. 230 MK=0
  284. 240 repeat
  285.  
  286. Resets the value of MK to zero, and then starts a REPEAT loop.  
  287. This is so that it can alter the value of MK if needed, or leave 
  288. it alone.  As this is the first time that MK has been used it 
  289. would be defaulting to zero in anycase -I assume that you know 
  290. that MK is tha variable that is going to hold the value of the 
  291. mouse key - but we need a way of resetting it.
  292.  
  293. Lines:
  294. 250 K$=inkey$
  295. 260 if K$<>"" then default : end
  296.  
  297. Set up another variable.  This one tests to see if a key on the 
  298. keyboard has been pressed.  'K$' is whichever key - if any - has 
  299. been pressed.  THen it checks to see if 'K$' is empty {""} ie 
  300. nothing between the quotes.  If so then it terminates the 
  301. programme, if not it continues on to the next line.
  302.  
  303. Lines:
  304. 270 MK=mouse key
  305. 280 until MK<>0
  306.  
  307. Transfer the value of the mousekey pressed into the variable 'MK'. 
  308. Remember the mouse keys are valued at 1 = left; 2 = right; and 3 = 
  309. both keys.  If 'MK' has no value - no mouse key has been pressed, 
  310. then the programme loops back to the start of the REPEAT command 
  311. UNTIL 'MK' has a value other than zero.
  312.  
  313. Lines:
  314. 290 rem
  315. 300 locate 10,10
  316. 330 print zone(0)
  317. 350 goto 200
  318.  
  319. Update the printout on screen of which zone the mouse is in.  This 
  320. only happens if any mouse key is pressed.
  321.  
  322. Lines:
  323. 1000 data 0,0,32,18,32,0,63,18
  324. 1010 data 0,19,32,37,32,19,63,37
  325. 1020 data 0,38,32,66,32,38,63,66
  326. 1030 data 0,67,32,95,32,67,63,95
  327. 1040 data 0,96,63,119
  328. 1230 data 0,67,32,95,32,67,63,95
  329.  
  330. Are the same data statements as in lesson 1, so I will not go into 
  331. them again.
  332.  
  333. There was not much to that programme.  All I wanted to alow you 
  334. was how the zones would work on the larger programmes which are to 
  335. follow.
  336.  
  337.  
  338.  
  339. lesson 3
  340.  
  341. Lines 690 & 700; 740 & 750; 840 & 850 were deleted
  342.  
  343. This lesson loads a picture; a packed  file - one that has been 
  344. squashed - than displays them to screen and waits for a key press 
  345. before quitting.
  346.  
  347. 10 rem **************************
  348. 20 rem ***                    ***
  349. 30 rem ***     JIGSAW   1     ***
  350. 40 rem ***                    ***
  351. 50 rem **************************
  352. 60 if mode<>0 then mode 0
  353. 70 cls : key off : curs off : hide on
  354. 80 if length(1)<>0 then goto 190
  355. 90 DRV=drive : drive=0 : dir$="A:\"
  356. 100 if length(6)=0 then reserve as screen 6
  357. 110 if length(7)=0 then reserve as screen 7
  358. 120 rem
  359. 130 locate 10,10 : print "LOAD PICTURE" : wait 50
  360. 140 cls : show on : SCR$=file select$("*.*")
  361. 150 F$=SCR$ : BNK=6 : gosub 380
  362. 160 rem
  363. 170 locate 10,10 : print "LOAD PACed FILE" : wait 50
  364. 180 show on : PSCR$=file select$("*.pac")
  365. 190 F$=PSCR$ : BNK=8 : gosub 500
  366. 200 rem
  367. 210 rem
  368. 220 rem
  369. 230 rem
  370. 240 get palette (6)
  371. 250 screen copy 6 to back : screen copy 6 to physic
  372. 260 reduce 6 to 7,64,0,319,199
  373. 270 reduce 6 to 7,0,120,64,199
  374. 280 fade 5
  375. 290 fade 5,6
  376. 300 get palette (6)
  377. 310 appear 7
  378. 320 rem
  379. 330 wait 100 : goto 610
  380. 340 rem
  381. 350 rem
  382. 360 rem ------ FILE LOADER
  383. 370 rem
  384. 380 hide on : load F$,BNK
  385. 390 locate 10,10
  386. 400 print F$;" IS LOADED" : wait 50
  387. 410 cls : return
  388. 420 rem
  389. 430 rem ----- PACed FILE LOADER
  390. 440 rem
  391. 450 locate 10,10 : print "LOAD PACed FILE" : wait 50
  392. 460 if length(7)=0 then reserve as screen 7
  393. 470 rem
  394. 480 rem  get size of file to unsquash
  395. 490 rem
  396. 500 open in #1,F$ : LF=lof(#1) : close #1
  397. 510 reserve as work BNK,LF
  398. 520 hide on : bload F$,BNK
  399. 530 rem
  400. 540 rem  unsquashing file in a screen bank
  401. 550 rem
  402. 560 copy start(8),start(8)+LF to start(7)
  403. 570 unsquash 7,LF
  404. 580 locate 10,10
  405. 590 print F$;" IS LOADED" : wait 50
  406. 600 cls : return
  407. 610 show on
  408. 620 reset zone
  409. 630 for F=1 to 9
  410. 640 read A,B,C,D
  411. 650 set zone F,A,B to C,D
  412. 660 box A,B to C,D
  413. 670 next F
  414. 680 rem
  415. 710 rem
  416. 720 rem
  417. 730 rem
  418. 760 rem
  419. 770 MK=0
  420. 780 repeat
  421. 790 K$=inkey$
  422. 800 if K$<>"" then default : end
  423. 810 MK=mouse key
  424. 820 until MK<>0 
  425. 830 rem 
  426. 860 goto 770 
  427. 870 data 0,0,32,18,32,0,63,18 
  428. 880 data 0,19,32,37,32,19,63,37 
  429. 890 data 0,38,32,66,32,38,63,66 
  430. 900 data 0,67,32,95,32,67,63,95 
  431. 910 data 0,96,63,119 
  432. 920 data 0,67,32,95,32,67,63,95 
  433.  
  434. If you think this is a long programme, than the final lesson is 
  435. twice as long.  But do not panic.  Much of the listing is REM 
  436. statements to help you, and the rest has very little in it that is 
  437. new to you, so it wont be too hard.
  438.  
  439. Lines:
  440. 10 rem **************************
  441. 20 rem ***                    ***
  442. 30 rem ***     JIGSAW   1     ***
  443. 40 rem ***                    ***
  444. 50 rem **************************
  445.  
  446. Well you know what this is the title.  This time I decided to 
  447. number the first programme.  Sometimes I forget/dont bother.
  448.  
  449. Lines:
  450. 60 if mode<>0 then mode 0
  451. 70 cls : key off : curs off : hide on
  452. 80 if length(1)<>0 then goto 190
  453. 90 DRV=drive : drive=0 : dir$="A:\"
  454.  
  455. Set up the screen and default drives.  I am getting tired of 
  456. defaulting to the root of drive A:, so I will be introducing a 
  457. better system in the last lesson of this tutorial.
  458.  
  459. Once the Screen has been set up, the programme checks to see if 
  460. Memory Bank 1 is empty or not in line 80.  If it is empty, the 
  461. programme contunues at the next line, if not then it skips the 
  462. lines that it does not need and jumps to line 190.
  463.  
  464. Basically this is a way of ensuring that the programme does not 
  465. reset the read lins that it does not need to.  After all, if the 
  466. programme is just starting, then all the banks will be empty, but 
  467. if it is returning after having completed a jigsaw - or in this 
  468. case loaded the banks, done what it was meant to and then ended - 
  469. we might not want it to load the banks again.
  470.  
  471. So it is a way of saving time.
  472.  
  473. Lines:
  474. 100 if length(6)=0 then reserve as screen 6
  475. 110 if length(7)=0 then reserve as screen 7
  476.  
  477. Check to see if banks six and seven are in place or not.  You can 
  478. only reserve the bank once, once it is there yoou can use it as 
  479. you wish - provided you load the correct data into it, i.e. 
  480. sprites into a sprite bank and pictures into a picture bank.
  481.  
  482. There is a slight problem with thest screen banks.  I decided to 
  483. use temporary banks.  So they do sometimes disapear after the 
  484. programm had ended, and sometimes they remain.  It depends on what 
  485. you do in the editor screen.
  486.  
  487. Temporary banks are reserved as SCREENs.
  488.  
  489. Permenant banks are reserved ad DATA SCREENS.
  490.  
  491. The difference is that permenant banks are saved with the 
  492. programme, and always remain.  So you do not need to check them.  
  493. However, I am not saving  as a BASic file so there is little point 
  494. in using permenant screens.
  495.  
  496. Lines:
  497. 120 rem
  498. 130 locate 10,10 : print "LOAD PICTURE" : wait 50
  499.  
  500. Prints a message telling you to load a picture.  Actually it would 
  501. have been better to place the message at the top of the screen.  
  502. Then you would see is whilst the file selector was working.
  503.  
  504. Lines:
  505. 140 cls : show on : SCR$=file select$("*.*")
  506. 150 F$=SCR$ : BNK=6 : gosub 380
  507.  
  508. Clears the screen of the message, and then displays the mouse, and 
  509. then the file selector to alow you to load a file.  It then loads 
  510. this file into Bank six by jumping to a routine at line 380.
  511.  
  512. Lines:
  513. 160 rem
  514. 170 locate 10,10 : print "LOAD PACed FILE" : wait 50
  515. 180 show on : PSCR$=file select$("*.pac")
  516. 190 F$=PSCR$ : BNK=8 : gosub 500
  517.  
  518. Do the same thing as the previous lines, but this time a PACked 
  519. file is going to be nominated in the routine at line 500.
  520.  
  521. Lines:
  522. 200 rem
  523. 210 rem
  524. 220 rem
  525. 230 rem
  526. 240 get palette (6)
  527. 250 screen copy 6 to back : screen copy 6 to physic
  528.  
  529. Load the palette from Bank six - this is the colour of the picture 
  530. loaded in there - and then copy the contents of Bank six to the 
  531. screen.  You need to do both the Physical and Background screen so 
  532. that the mouse does not erase bits of the screen as it moves.  
  533. Remember that the mouse is a sprite, and the screen is updated if 
  534. a sprite moves.
  535.  
  536. Line:
  537. 260 reduce 6 to 7,64,0,319,199
  538.  
  539. Shrinks the picture by the determined amount.  The only real limit 
  540. to this command is that it only works in multiples of 16.  So
  541. 'REDUCE 6 to 7,64,0,319,199'
  542. is the same as
  543. 'REDUCE 6 to 7, 66,0,319,199'
  544.  
  545. In the case above, it shrinks from bank 6 to bank 7, and from full 
  546. screen to 64,0,319,199.  That is from 64 pixels across, 0 pixels 
  547. down - a pixel being a single dot on the screen - to 319 across 
  548. and 199 down.  Which is to the end of the screen.
  549.  
  550. Line:
  551. 270 reduce 6 to 7,0,120,64,199
  552.  
  553. Does the same as the previous line, but this time copies to the 
  554. bottom left hand corner of the sceen stored in Bank 7.
  555.  
  556. Remember this is being drawn to a screen bank, so you will not see 
  557. it untill you display that Bank to screen.
  558.  
  559. Lines:
  560. 280 fade 5
  561. 290 fade 5,6
  562. 300 get palette (6)
  563. 310 appear 7
  564.  
  565. Fades the screen at a speed of 5, then fades back but this time 
  566. displaying the screen stored in Bank 6.  Then it get the palette 
  567. of Bank 6, and then displays bank 7.  Remember bank 7 is where the 
  568. pictures have been REDUCEd to,  This is why we take bank 6 palette 
  569. and not bank 7.  
  570.  
  571. Basically, bank 7 has a palette of its own.  anything copied into 
  572. bank 7, which already holds part of a picture, will take on the 
  573. palette of bank 7.  So you need to display the palette from where 
  574. the pictures were REDUCED from rather than REDUCED to.
  575.  
  576. Lines:
  577. 320 rem
  578. 330 wait 100 : goto 610
  579.  
  580. Just set up a short delay period so that you can see the screen , 
  581. and then jump to line 610.
  582.  
  583. Lines:
  584. 340 rem
  585. 350 rem
  586. 360 rem ------ FILE LOADER
  587. 370 rem
  588.  
  589. This is the standard file loader.
  590.  
  591. Line:
  592. 380 hide on : load F$,BNK
  593.  
  594. Removes the mouse, and loads the file into the Bank number BNK.
  595.  
  596. Lines:
  597. 390 locate 10,10
  598. 400 print F$;" IS LOADED" : wait 50
  599. 410 cls : return
  600.  
  601. Inform you that the file was loaded and then clears the screen and 
  602. return to wherever it jumped from.
  603.  
  604. Lines:
  605. 420 rem
  606. 430 rem ----- PACed FILE LOADER
  607. 440 rem
  608.  
  609. This is the PACked file loader.  i.e. it loads squashed files with 
  610. the PAC extension.
  611.  
  612. Lines:
  613. 450 locate 10,10 : print "LOAD PACed FILE" : wait 50
  614. 460 if length(7)=0 then reserve as screen 7
  615.  
  616. Prints a message and reserve a screen.
  617.  
  618. Line:
  619. 470 rem
  620. 480 rem  get size of file to unsquash
  621. 490 rem
  622.  
  623. Are the start of the unsqashing routine.
  624.  
  625. Line:
  626. 500 open in #1,F$ : LF=lof(#1) : close #1
  627.  
  628. Opens a binary file.  Thats how memory banks are stored to disk, 
  629. as binary files.  This opens a file, and determins the length of 
  630. the file, stores this info in LF - Length of File - and then 
  631. closes the file.
  632.  
  633. I will go into this in more detail in the next tutorial, for now 
  634. it is enought that it works.
  635.  
  636. Lines:
  637. 510 reserve as work BNK,LF
  638. 520 hide on : bload F$,BNK
  639.  
  640. Reserves a work area to the length of the squashed file, and loads 
  641. the Packed file into this workspace.  It also hides the mouse.
  642.  
  643. The reason for the mouse being hidden, is so that when it is 
  644. displayed, you know that you have do do something.  When it is 
  645. hidden you know the computer is working on something.
  646.  
  647. Lines:
  648. 530 rem
  649. 540 rem  unsquashing file in a screen bank
  650. 550 rem
  651.  
  652. Ser the start od the actual UNSQUASHING.
  653.  
  654. Line:
  655. 560 copy start(8),start(8)+LF to start(7)
  656.  
  657. Copies the file from bank 8 to bank 7.  It only copies the actual 
  658. amount of data that is required.  You can store more than one 
  659. picture to a bank in PACked form, but I will explaine that in the 
  660. next tutorial.
  661.  
  662. Line:
  663. 570 unsquash 7,LF
  664.  
  665. UNSQUASHES the copied file.  it is now a picture again, and can be 
  666. displayed to screen.
  667.  
  668. Lines:
  669. 580 locate 10,10
  670. 590 print F$;" IS LOADED" : wait 50
  671. 600 cls : return
  672.  
  673. Display a message and then tidy up before returning to where it 
  674. jumped from.
  675.  
  676. Lines:
  677. 610 show on
  678. 620 reset zone
  679. 630 for F=1 to 9
  680. 640 read A,B,C,D
  681. 650 set zone F,A,B to C,D
  682. 660 box A,B to C,D
  683. 670 next F
  684.  
  685. Were discussed in the first lesson.  The only new point here is 
  686. the fact that the mouse is redisplayed to screen.
  687.  
  688. Lines:
  689. 680 rem
  690. 710 rem
  691. 720 rem
  692. 730 rem
  693. 760 rem
  694.  
  695. Should really have been deleted.  I was going to add some code, so 
  696. I made some rems, but then I changed my mind, and forgot to delete 
  697. and renum.
  698.  
  699. Lines:
  700. 770 MK=0
  701. 780 repeat
  702. 790 K$=inkey$
  703. 800 if K$<>"" then default : end
  704. 810 MK=mouse key
  705. 820 until MK<>0
  706.  
  707. Have also been dealt with in lesson 1
  708.  
  709. Lines:
  710. 830 rem
  711. 860 goto 770
  712. 870 data 0,0,32,18,32,0,63,18
  713. 880 data 0,19,32,37,32,19,63,37
  714. 890 data 0,38,32,66,32,38,63,66
  715. 900 data 0,67,32,95,32,67,63,95
  716. 910 data 0,96,63,119
  717. 920 data 0,67,32,95,32,67,63,95
  718.  
  719. Were also dealt with in lesson 1.
  720.  
  721. Gosh, this is already 11 pages long, and I still have to deal with 
  722. the last programme yet.
  723.  
  724.  
  725.  
  726. lesson 4
  727.  
  728. This is a slight modification of JIGSAW 1.  It loads sprites which 
  729. will store the picture, then loads the picture and the packed 
  730. screen.  Displays things and then quits.
  731.  
  732. 10 rem **************************
  733. 20 rem ***                    ***
  734. 30 rem ***     JIGSAW   2     ***
  735. 40 rem ***                    ***
  736. 50 rem **************************
  737. 60 if mode<>0 then mode 0
  738. 70 cls : key off : curs off : hide on
  739. 80 DRV=drive : drive=0 : dir$="A:\"
  740. 90 rem
  741. 100 HT=39 : WD=48
  742. 110 X1=63 : X2=196 : Y1=2 : Y2=319
  743. 120 JIG=25 : JHT=39 : JWD=48
  744. 130 rem
  745. 140 rem ------ grab sprites & make jigsaw
  746. 150 rem
  747. 160 if length(1)<>0 then goto 240
  748. 170 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  749. 180 cls : show on : SPR$=file select$("*.MBK")
  750. 190 F$=SPR$ : BNK=1 : gosub 530
  751. 200 rem
  752. 210 rem
  753. 220 rem ---- Load a picture
  754. 230 rem
  755. 240 if length(6)<>0 then goto 320
  756. 250 if length(6)=0 then reserve as screen 6
  757. 260 locate 10,10 : print "LOAD PICTURE" : wait 50
  758. 270 cls : show on : SCR$=file select$("*.*")
  759. 280 F$=SCR$ : BNK=6 : gosub 530
  760. 290 rem
  761. 300 rem ---- Load a packed screen
  762. 310 rem
  763. 320 if length(7)<>0 then goto 390
  764. 330 if length(7)=0 then reserve as screen 7
  765. 340 locate 10,10 : print "LOAD PACed FILE" : wait 50
  766. 350 show on : PSCR$=file select$("*.pac")
  767. 360 F$=PSCR$ : BNK=8 : gosub 650
  768. 370 rem
  769. 380 rem
  770. 390 get palette (6)
  771. 400 screen copy 6 to back : screen copy 6 to physic
  772. 410 reduce 6 to 7,64,0,304,199
  773. 420 reduce 6 to 7,0,120,64,199
  774. 430 fade 5
  775. 440 fade 5,6
  776. 450 get palette (6)
  777. 460 screen copy 7 to back : screen copy 7 to physic
  778. 470 rem
  779. 480 wait 100 : goto 760
  780. 490 rem
  781. 500 rem
  782. 510 rem ------ FILE LOADER
  783. 520 rem
  784. 530 hide on : load F$,BNK
  785. 540 locate 10,10
  786. 550 print F$;" IS LOADED" : wait 50
  787. 560 cls : return
  788. 570 rem
  789. 580 rem ----- PACed FILE LOADER
  790. 590 rem
  791. 600 locate 10,10 : print "LOAD PACed FILE" : wait 50
  792. 610 if length(7)=0 then reserve as screen 7
  793. 620 rem
  794. 630 rem  get size of file to unsquash
  795. 640 rem
  796. 650 open in #1,F$ : LF=lof(#1) : close #1
  797. 660 reserve as work BNK,LF
  798. 670 hide on : bload F$,BNK
  799. 680 rem
  800. 690 rem  unsquashing file in a screen bank
  801. 700 rem
  802. 710 copy start(8),start(8)+LF to start(7)
  803. 720 unsquash 7,LF
  804. 730 locate 10,10
  805. 740 print F$;" IS LOADED" : wait 50
  806. 750 cls : return
  807. 760 show on
  808. 770 reset zone
  809. 780 for F=1 to 9
  810. 790 read A,B,C,D
  811. 800 set zone F,A,B to C,D
  812. 810 box A,B to C,D
  813. 820 next F
  814. 830 rem
  815. 840 MK=0
  816. 850 repeat
  817. 860 K$=inkey$
  818. 870 rem
  819. 880 MK=mouse key
  820. 890 until MK<>0
  821. 900 rem
  822. 910 if zone(0)=6 then goto 980
  823. 920 if zone(0)=9 then shoot : wait 100 : default : end
  824. 930 goto 840
  825. 940 rem
  826. 950 rem ***  draw jigsaw grid  ***
  827. 960 rem
  828. 970 rem
  829. 980 JHT=39 : JWD=48
  830. 990 rem
  831. 1000 X1=63 : X2=196 : Y1=2 : Y2=319
  832. 1010 X3=X1+JWD : Y3=Y1+JHT
  833. 1020 for F=1 to JIG
  834. 1030 box X1,Y1 to X3,Y3
  835. 1040 X3=X3+JWD
  836. 1050 if X3>=Y2 then X3=X1+JWD : Y1=Y1+JHT : Y3=Y1+JHT
  837. 1060 next F
  838. 1070 change mouse 4
  839. 1080 rem
  840. 1090 rem
  841. 1100 rem
  842. 1110 X=64 : Y=0
  843. 1120 for F=1 to JIG
  844. 1130 get sprite X,Y,F
  845. 1140 X=X+JIG
  846. 1150 if X>304-JWD then X=64 : Y=Y+JHT
  847. 1160 next F
  848. 1170 cls : wait 100
  849. 1180 X=64 : Y=0
  850. 1190 for F=1 to JIG
  851. 1200 sprite 1,X,Y,F
  852. 1210 wait vbl : put sprite 1
  853. 1220 X=X+JIG
  854. 1230 if X>=304 then X=64 : Y=Y+JHT
  855. 1240 next F
  856. 1250 cls
  857. 1260 dim LST(JIG),CH(JIG+1)
  858. 1270 for F=0 to JIG
  859. 1280 CH(F)=F
  860. 1290 next F
  861. 1300 cls
  862. 1310 repeat
  863. 1320 NUM=rnd(JIG)+1
  864. 1330 if LST(N)=0 and CH(NUM)<>0 then LST(N)=CH(NUM) else goto 1310
  865. 1340 inc N : CH(NUM)=0
  866. 1350 until N=JIG
  867. 1360 X=64 : Y=0
  868. 1370 for F=1 to JIG
  869. 1380 sprite 1,X,Y,LST(F-1)
  870. 1390 wait vbl : put sprite 1
  871. 1400 X=X+JWD
  872. 1410 if X>=304 then X=64 : Y=Y+JHT
  873. 1420 next F
  874. 1430 rem
  875. 1440 rem
  876. 1450 rem
  877. 1460 wait 200 : print "ABOUT TO QUIT PLEASE WAIT" : default : end 
  878. 1470 rem
  879. 1480 rem
  880. 1490 data 0,0,32,18,32,0,63,18
  881. 1500 data 0,19,32,37,32,19,63,37
  882. 1510 data 0,38,32,66,32,38,63,66
  883. 1520 data 0,67,32,95,32,67,63,95
  884. 1530 data 0,96,63,119
  885. 1540 data 0,67,32,95,32,67,63,95
  886.  
  887. Although longer than the previous lesson, it is not really that 
  888. much different from it.
  889.  
  890. Lines:
  891. 10 rem **************************
  892. 20 rem ***                    ***
  893. 30 rem ***     JIGSAW   2     ***
  894. 40 rem ***                    ***
  895. 50 rem **************************
  896.  
  897. Are the title.
  898.  
  899. Lines:
  900. 60 if mode<>0 then mode 0
  901. 70 cls : key off : curs off : hide on
  902. 80 DRV=drive : drive=0 : dir$="A:\"
  903.  
  904. Are the same as the previous lesson.
  905.  
  906. Lines:
  907. 90 rem
  908. 100 HT=39 : WD=48
  909. 110 X1=63 : X2=196 : Y1=2 : Y2=319
  910. 120 JIG=25 : JHT=39 : JWD=48
  911.  
  912. Store the variables needed to set up the screen.  Ht= height; WD = 
  913. width of the sprites.  X1, Y1 etc.. are the locations whet tha 
  914. picture will be drawn to screen in reduced form.  JIG is the 
  915. number of sprites in the bank, and thus the number of pieces of 
  916. the jigsaw, and JHT and JWD are variables that also store the 
  917. width and height of the sprites in case I want to change them, but 
  918. also keep a default value as well.
  919.  
  920. Lines:
  921. 130 rem
  922. 140 rem ------ grab sprites & make jigsaw
  923. 150 rem
  924. 160 if length(1)<>0 then goto 240
  925. 170 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  926. 180 cls : show on : SPR$=file select$("*.MBK")
  927. 190 F$=SPR$ : BNK=1 : gosub 530
  928.  
  929. Were dealt with in lesson 3 and loads a sprite bank.
  930.  
  931. Lines:
  932. 200 rem
  933. 210 rem
  934. 220 rem ---- Load a picture
  935. 230 rem
  936. 240 if length(6)<>0 then goto 320
  937. 250 if length(6)=0 then reserve as screen 6
  938. 260 locate 10,10 : print "LOAD PICTURE" : wait 50
  939. 270 cls : show on : SCR$=file select$("*.*")
  940. 280 F$=SCR$ : BNK=6 : gosub 530
  941.  
  942. Were dealt with in lesson 3 and loads a screen bank. 
  943.  
  944. Lines:
  945. 290 rem
  946. 300 rem ---- Load a packed screen
  947. 310 rem
  948. 320 if length(7)<>0 then goto 390
  949. 330 if length(7)=0 then reserve as screen 7
  950. 340 locate 10,10 : print "LOAD PACed FILE" : wait 50
  951. 350 show on : PSCR$=file select$("*.pac")
  952. 360 F$=PSCR$ : BNK=8 : gosub 650
  953.  
  954. Were dealt with in lesson 3 and load a PACked file.
  955.  
  956. Lines:
  957. 370 rem
  958. 380 rem
  959. 390 get palette (6)
  960. 400 screen copy 6 to back : screen copy 6 to physic
  961. 410 reduce 6 to 7,64,0,304,199
  962. 420 reduce 6 to 7,0,120,64,199
  963. 430 fade 5
  964. 440 fade 5,6
  965. 450 get palette (6)
  966. 460 screen copy 7 to back : screen copy 7 to physic
  967.  
  968. Were also dealt with in lesson 3.  They take the screen from bank 
  969. 6 and reduce it and copy it to bank 7.  The only point worth 
  970. noteing is that I am building up a screen from segments of Bank 6 
  971. and adding them together to form one picture.
  972.  
  973. Lines:
  974. 470 rem
  975. 480 wait 100 : goto 760
  976.  
  977. Wait a short time and then jumps to line 760.  This is to give you 
  978. time to look at the picture.
  979.  
  980. Lines:
  981. 490 rem
  982. 500 rem
  983. 510 rem ------ FILE LOADER
  984. 520 rem
  985. 530 hide on : load F$,BNK
  986. 540 locate 10,10
  987. 550 print F$;" IS LOADED" : wait 50
  988. 560 cls : return
  989.  
  990. Were dealt with in lesson 3 and are the file loaders.
  991.  
  992. 570 rem
  993. 580 rem ----- PACed FILE LOADER
  994. 590 rem
  995. 600 locate 10,10 : print "LOAD PACed FILE" : wait 50
  996. 610 if length(7)=0 then reserve as screen 7
  997. 620 rem
  998. 630 rem  get size of file to unsquash
  999. 640 rem
  1000. 650 open in #1,F$ : LF=lof(#1) : close #1
  1001. 660 reserve as work BNK,LF
  1002. 670 hide on : bload F$,BNK
  1003. 680 rem
  1004. 690 rem  unsquashing file in a screen bank
  1005. 700 rem
  1006. 710 copy start(8),start(8)+LF to start(7)
  1007. 720 unsquash 7,LF
  1008. 730 locate 10,10
  1009. 740 print F$;" IS LOADED" : wait 50
  1010. 750 cls : return
  1011.  
  1012. Were dealt with in lesson 3 and are the file loaders.
  1013.  
  1014. Lines:
  1015. 760 show on
  1016. 770 reset zone 780 for F=1 to 9
  1017. 790 read A,B,C,D
  1018. 800 set zone F,A,B to C,D
  1019. 810 box A,B to C,D
  1020. 820 next F
  1021.  
  1022. Were dealt with in lesson 1 and set up the zones.  THes zones are 
  1023. there so that you can control the game once it is up an running.  
  1024. At this moment in time they de very little, but in lesson 5 you 
  1025. will see what they do.
  1026.  
  1027. Lines:
  1028. 830 rem
  1029. 840 MK=0
  1030. 850 repeat
  1031. 860 K$=inkey$
  1032. 870 rem
  1033. 880 MK=mouse key
  1034. 890 until MK<>0
  1035.  
  1036. Were explained in lesson 1 and set up a loop to test for a key or 
  1037. mouse key being pressed.  In this case 'K$' does not do any thing, 
  1038. and could have been removed.
  1039.  
  1040. Lines:
  1041. 900 rem
  1042. 910 if zone(0)=6 then goto 980
  1043. 920 if zone(0)=9 then shoot : wait 100 : default : end
  1044. 930 goto 840
  1045.  
  1046. Test for the zones.  It tests for ZONE(0) becaus the mouse is 
  1047. sprite zero, and that is what we are testing for.  It could take 
  1048. the form ZONE(0) to ZONE(15) as there are 16 sprites to choose 
  1049. from at any one time.
  1050.  
  1051. Lines:
  1052. 940 rem
  1053. 950 rem ***  draw jigsaw grid  ***
  1054. 960 rem
  1055. 970 rem
  1056.  
  1057. Are the start of the actual jigsaw drawing bit.
  1058.  
  1059. Line:
  1060. 980 JHT=39 : JWD=48
  1061.  
  1062. Sets the size of a jigsaw piece.
  1063.  
  1064. Lines:
  1065. 990 rem
  1066. 1000 X1=63 : X2=196 : Y1=2 : Y2=319
  1067. 1010 X3=X1+JWD : Y3=Y1+JHT
  1068.  
  1069. Set the location to draw to.
  1070.  
  1071. Lines:
  1072. 1020 for F=1 to JIG
  1073. 1030 box X1,Y1 to X3,Y3
  1074. 1040 X3=X3+JWD
  1075. 1050 if X3>=Y2 then X3=X1+JWD : Y1=Y1+JHT : Y3=Y1+JHT
  1076. 1060 next F
  1077.  
  1078. Set up a loop to draw boxes to screen.  These boxes are tha same 
  1079. sise as the sprites that will form the jigsaw pieces.
  1080.  
  1081. Line:
  1082. 1070 change mouse 4
  1083.  
  1084. Changes the mouse into the first sprite in the sprite bank.  Thus 
  1085. it changes it into a piece of the jigsaw if one is available.
  1086.  
  1087. Lines:
  1088. 1080 rem
  1089. 1090 rem
  1090. 1100 rem
  1091. 1110 X=64 : Y=0
  1092. 1120 for F=1 to JIG
  1093. 1130 get sprite X,Y,F
  1094. 1140 X=X+JIG
  1095. 1150 if X>304-JWD then X=64 : Y=Y+JHT
  1096. 1160 next F
  1097.  
  1098. Copy the screen to the sprite bank.  The routine checks to see how 
  1099. far across the screen it is against how wide the sprites are.
  1100.  
  1101. Line:
  1102. 1170 cls : wait 100
  1103.  
  1104. Waits a short time after clearing the screen.
  1105.  
  1106. Lines:
  1107. 1180 X=64 : Y=0
  1108. 1190 for F=1 to JIG
  1109. 1200 sprite 1,X,Y,F
  1110. 1210 wait vbl : put sprite 1
  1111. 1220 X=X+JIG
  1112. 1230 if X>=304 then X=64 : Y=Y+JHT
  1113. 1240 next F
  1114.  
  1115. Are much the same as the previous lines, except this time they are 
  1116. placing the sprites to screen to form a picture.
  1117.  
  1118. Line:
  1119. 1250 cls
  1120.  
  1121. Clears the screen ready for the scrambling of the jigsaw.
  1122.  
  1123. Lines:
  1124. 1260 dim LST(JIG),CH(JIG+1)
  1125. 1270 for F=0 to JIG
  1126. 1280 CH(F)=F
  1127. 1290 next F
  1128. 1300 cls
  1129.  
  1130. Are where the new sprite order is stored. I will discuss this in 
  1131. detail in the next tutorial.  I have already touched on it in a 
  1132. previous tutorial, but will go over it again anyway.
  1133.  
  1134. Lines:
  1135. 1310 repeat
  1136. 1320 NUM=rnd(JIG)+1
  1137. 1330 if LST(N)=0 and CH(NUM)<>0 then LST(N)=CH(NUM) else goto 1310
  1138. 1340 inc N : CH(NUM)=0
  1139. 1350 until N=JIG
  1140. 1360 X=64 : Y=0
  1141. 1370 for F=1 to JIG
  1142. 1380 sprite 1,X,Y,LST(F-1)
  1143. 1390 wait vbl : put sprite 1
  1144. 1400 X=X+JWD
  1145. 1410 if X>=304 then X=64 : Y=Y+JHT
  1146. 1420 next F
  1147.  
  1148. Displays the jumbled pieced back to screen.  Again I will explain 
  1149. this in more deatail next time. But it was also dealt with in the 
  1150. same tutorial as the previous lines.
  1151.  
  1152. Lines:
  1153. 1430 rem
  1154. 1440 rem
  1155. 1450 rem
  1156. 1460 wait 200 : print "ABOUT TO QUIT PLEASE WAIT" : default : end
  1157.  
  1158. Just tell you that the programme is about to end. then it does 
  1159. just that.
  1160.  
  1161. Lines:
  1162. 1470 rem
  1163. 1480 rem
  1164. 1490 data 0,0,32,18,32,0,63,18
  1165. 1500 data 0,19,32,37,32,19,63,37
  1166. 1510 data 0,38,32,66,32,38,63,66
  1167. 1520 data 0,67,32,95,32,67,63,95
  1168. 1530 data 0,96,63,119
  1169. 1540 data 0,67,32,95,32,67,63,95
  1170.  
  1171. Are the same as the previous data statements in principle, so I 
  1172. will not dwell on them here.
  1173.  
  1174.  
  1175. Due to problems with my computer repeadedly crashing - I have a 
  1176. faulty programme somewhere but cannot locate which one it is - I 
  1177. am not going to be able to deal with this final lesson in much 
  1178. detail.  I will sort out the problem and include This lesson in 
  1179. next months ot the month after that.
  1180.  
  1181. It also means that I have not been able to check for typeing 
  1182. errors, so if there are any mistakes, then just look at the keys 
  1183. around  the problem word.  i.e. THEN could be RHEN etc..
  1184.  
  1185.  PLEASE CLICK ON BASIC TUT 10/2 For next part of this Tutorial
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.